<?php
$dbh = new PDO('mysql:host=localhost;dbname=blog', 'root', '');

// Check if a blog title already exists
function blogExists($dbh, $blogTitle) {
    $sql = "SELECT COUNT(*) AS cnt FROM blogList WHERE blogTitle=".$dbh->quote($blogTitle);		
		$row = $dbh->prepare($sql);
    //$stmt->execute($sql);							 
    //$row = $dbh->prepare($sql);
		$row = $dbh->exec();
    return !empty($row['cnt' ]);
}

// Get the requested blog
function getBlog($dbh) {
    $sql = "SELECT blogText FROM blogList WHERE blogTitle = '$_POST[blogTitle]'";
		echo htmlentities($sql, ENT_QUOTES);
    $blog = $dbh->prepare($sql);		
		return $dbh->exec($sql);
}

$blog = getBlog($dbh);
$error = '' ;
$success = '' ;
//$blog = isset($_POST['blogTitle' ]) ? $_POST['blogTitle' ] : '' ;
/*  if ($_SERVER['REQUEST_METHOD' ] == 'POST' ) {
	  if (updateBlog($dbh, $blogTitle, $blogText)) {
        $success = "blog has been updated.";
		}
    elseif (!blogExists($dbh, $blogTitle)) {
        $error = "Blog Title does not exist.";
    }
}*/
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Edit Blog</title>
</head>
<body>

 

<form action="editBlog2.php" method="post">
Blog Title:<br/>
<input type="text" name="blogTitle" id="blogTitle"/><br/>
<br/><br/>
Blog Text:<br/>
<input type="text" name="blogText" id="blogText"/>
<input type="submit" value="Submit" name="btSubmit"/>
</form>


<br/><br/>
<a href="/blog_Home.php">
<img src="Images/home_button.gif" alt="Blog Page"/></a>
</body>
</html>
